package main

import (
	"lht-go-plugins/LhtLog"
	"lht-go-plugins/LhtPlugins/Spectrum"
	"lht-go-plugins/LhtSettings"
	"lht-go-plugins/LhtWebApi"
	"lht-go-plugins/internal/core"
	"lht-go-plugins/internal/server"
	"strconv"
)

func main() {
	manager := core.NewPluginManager()
	err := LhtSettings.InitConfiguration()
	if err != nil {

		return
	}
	//日志系统初始化
	LhtLog.InitLogger(LhtSettings.Conf.ZapLogConfig)
	LhtLog.Logger.Info("日志服务启动")
	{
		//Redis插件初始化与注册
		//redis := Cache.NewRedisPlugin()
		//_ = redis.Init(LhtSettings.Conf.RedisConfig)
		//LhtLog.Logger.Info("redis插件 初始化完成")

		//dbMysql := database.NewDatabasePlugin(LhtSettings.Conf.MysqlConfig)
		//dbMongo := database.NewDatabasePlugin(LhtSettings.Conf.MongoConfig)
		//dbPostgres := database.NewDatabasePlugin(LhtSettings.Conf.PostgresConfig)
		//
		//_ = dbMysql.(core.Plugin).Init(LhtSettings.Conf.MysqlConfig)
		//_ = dbMongo.(core.Plugin).Init(LhtSettings.Conf.MongoConfig)
		//_ = dbPostgres.(core.Plugin).Init(LhtSettings.Conf.PostgresConfig)

		//encrypt := Encrypt.NewEncryptPlugin()
		//encrypt.Init(nil)
		//LhtLog.Logger.Info("加密插件 初始化完成")
		//
		//ippsPlugin := IntelIpps.NewIppsPlugin()
		//ippsPlugin.Init(nil)
		//LhtLog.Logger.Info("ipps插件 初始化完成")

		//manager.Register(redis)
		//manager.Register(dbMysql.(core.Plugin))
		//manager.Register(dbMongo.(core.Plugin))
		//manager.Register(dbPostgres.(core.Plugin))
		//manager.Register(encrypt)
		//manager.Register(ippsPlugin)
	}
	//analysis := ProtocolResolution.NewOCPlugin(9000)
	//manager.Register(analysis)
	spec := Spectrum.NewSpectrumPlugin()
	manager.Register(spec)
	//启动所有插件
	manager.StartAll()

	server.NewPluginServiceImpl(LhtSettings.Conf.AppConfig)

	LhtWebApi.NewWebServer()
	LhtLog.Logger.Info("GrpcServer启动，端口：" + strconv.Itoa(LhtSettings.Conf.AppConfig.GrpcPort))
	select {}
}
